// 数据拼装
export function ff_package(data) {
	let oneIcon = 0;
	let newData = [];

	//    初步数据结构
	data.forEach((item, index) => {
		let newDataItem = {};
		if (item.type == 2) {
			//  大屏
			newDataItem.type = "FULL";
			newDataItem.isTrue = true;
			newDataItem.brands = item.video.video;

		} else if (item.type == 3) {
			//  中屏
			newDataItem.type = "mediateFULL";
			newDataItem.isTrue = false;
			newDataItem.brands = item.video.video;

			newDataItem.bjSrc = [];
			let textArr = item.video.description.split("</p><p>");
			newDataItem.text01 = textArr[0].substring(3);
			newDataItem.text02 = textArr[1].substring(0, textArr[1].length - 4);
			newDataItem.bjSrc.push(item.background);
		} else if (item.type == 4) {
			console.log("item.videoitem.video====>", item.video);
			// 
			//  左屏
			newDataItem.type = "leftFULL";
			newDataItem.isTrue = false;

			newDataItem.brands = item.video.video;

			newDataItem.bjSrc = [];
			newDataItem.bjSrc.push(item.background);
			let textArr = item.video.description.split("</p><p>");
			newDataItem.text01 = textArr[0].substring(3);
			newDataItem.text02 = textArr[1].substring(0, textArr[1].length - 4);
			//    
		} else if (item.type == 1) {
			//  LOGO屏
			//    if(data[index+1] == "LOGO"){
			oneIcon++;
			newDataItem.type = "LOGO";
			newDataItem.isTrue = false;
			newDataItem.brands = [];
			newDataItem.id = `${newDataItem.type}_${index}`
			let newDataItemLi = [];
			newDataItem.bjSrc = [];
			newDataItem.bjSrc.push(item.background);

			item.logos.forEach((newItem, newIndex) => {
				let isIcon = oneIcon == 1 ? true : false;
				newDataItemLi.push({
					isIcon,
					Src: newItem.icon,
				});
				// ;
				if (
					newDataItemLi.length == 3 ||
					(newDataItemLi.length != 3 && newIndex + 1 == item.logos.length)
				) {
					newDataItem.brands.push({
						isDisplay: false,
						arr: newDataItemLi
					});
					newDataItemLi = [];
				}
			});

			// newDataItem.brands.push()

			//    }
		}
		newData.push(newDataItem);
	});

	let NewDatas = [];
	let isPass = true;
	//最终数据结构  
	newData.forEach((newItem, newIndex) => {
		//    
		if (newItem.type != "LOGO") {
			NewDatas.push(newItem);
		} else if (
			newItem.type == "LOGO" &&
			newData[newIndex + 1] != undefined &&
			newData[newIndex + 1].type == "LOGO" &&
			newData[newIndex + 2] != undefined &&
			newData[newIndex + 2].type == "LOGO" &&
			newData[newIndex + 3] != undefined &&
			newData[newIndex + 3].type == "LOGO" &&
			newData[newIndex + 4] != undefined &&
			newData[newIndex + 4].type == "LOGO" &&
			newData[newIndex + 5] != undefined &&
			newData[newIndex + 5].type == "LOGO" &&
			newData[newIndex + 6] != undefined &&
			newData[newIndex + 6].type == "LOGO" &&
			newData[newIndex + 7] != undefined &&
			newData[newIndex + 7].type == "LOGO" &&
			newData[newIndex + 8] != undefined &&
			newData[newIndex + 8].type == "LOGO" &&
			newData[newIndex + 9] != undefined &&
			newData[newIndex + 9].type == "LOGO" &&
			newData[newIndex + 10] != undefined &&
			newData[newIndex + 10].type == "LOGO"

		) {
			if (isPass) {
				isPass = false;
				let newItemss = {};
				newItemss.type = "LOGO";
				(newItemss.isTrue = false),
				(newItemss.bjSrc = [
					...newItem.bjSrc,
					...newData[newIndex + 1].bjSrc,
					...newData[newIndex + 2].bjSrc,
					...newData[newIndex + 3].bjSrc,
					...newData[newIndex + 4].bjSrc,
					...newData[newIndex + 5].bjSrc,
					...newData[newIndex + 6].bjSrc,
					...newData[newIndex + 7].bjSrc,
					...newData[newIndex + 8].bjSrc,
					...newData[newIndex + 9].bjSrc,
					...newData[newIndex + 10].bjSrc
				]);
				newItemss.brands = [
					...newItem.brands,
					[],
					...newData[newIndex + 1].brands,
					[],
					...newData[newIndex + 2].brands,
					[],
					...newData[newIndex + 3].brands,
					[],
					...newData[newIndex + 4].brands,
					[],
					...newData[newIndex + 5].brands,
					[],
					...newData[newIndex + 6].brands,
					[],
					...newData[newIndex + 7].brands,
					[],
					...newData[newIndex + 8].brands,
					[],
					...newData[newIndex + 9].brands,
					[],
					...newData[newIndex + 10].brands
				];
				NewDatas.push(newItemss);
			}
		} else if (
			newItem.type == "LOGO" &&
			newData[newIndex + 1] != undefined &&
			newData[newIndex + 1].type == "LOGO" &&
			newData[newIndex + 2] != undefined &&
			newData[newIndex + 2].type == "LOGO" &&
			newData[newIndex + 3] != undefined &&
			newData[newIndex + 3].type == "LOGO" &&
			newData[newIndex + 4] != undefined &&
			newData[newIndex + 4].type == "LOGO" &&
			newData[newIndex + 5] != undefined &&
			newData[newIndex + 5].type == "LOGO" &&
			newData[newIndex + 6] != undefined &&
			newData[newIndex + 6].type == "LOGO" &&
			newData[newIndex + 7] != undefined &&
			newData[newIndex + 7].type == "LOGO" &&
			newData[newIndex + 8] != undefined &&
			newData[newIndex + 8].type == "LOGO" &&
			newData[newIndex + 9] != undefined &&
			newData[newIndex + 9].type == "LOGO"

		) {
			if (isPass) {
				isPass = false;
				let newItemss = {};
				newItemss.type = "LOGO";
				(newItemss.isTrue = false),
				(newItemss.bjSrc = [
					...newItem.bjSrc,
					...newData[newIndex + 1].bjSrc,
					...newData[newIndex + 2].bjSrc,
					...newData[newIndex + 3].bjSrc,
					...newData[newIndex + 4].bjSrc,
					...newData[newIndex + 5].bjSrc,
					...newData[newIndex + 6].bjSrc,
					...newData[newIndex + 7].bjSrc,
					...newData[newIndex + 8].bjSrc,
					...newData[newIndex + 9].bjSrc
				]);
				newItemss.brands = [
					...newItem.brands,
					[],
					...newData[newIndex + 1].brands,
					[],
					...newData[newIndex + 2].brands,
					[],
					...newData[newIndex + 3].brands,
					[],
					...newData[newIndex + 4].brands,
					[],
					...newData[newIndex + 5].brands,
					[],
					...newData[newIndex + 6].brands,
					[],
					...newData[newIndex + 7].brands,
					[],
					...newData[newIndex + 8].brands,
					[],
					...newData[newIndex + 9].brands
				];
				NewDatas.push(newItemss);
			}
		} else if (
			newItem.type == "LOGO" &&
			newData[newIndex + 1] != undefined &&
			newData[newIndex + 1].type == "LOGO" &&
			newData[newIndex + 2] != undefined &&
			newData[newIndex + 2].type == "LOGO" &&
			newData[newIndex + 3] != undefined &&
			newData[newIndex + 3].type == "LOGO" &&
			newData[newIndex + 4] != undefined &&
			newData[newIndex + 4].type == "LOGO" &&
			newData[newIndex + 5] != undefined &&
			newData[newIndex + 5].type == "LOGO" &&
			newData[newIndex + 6] != undefined &&
			newData[newIndex + 6].type == "LOGO" &&
			newData[newIndex + 7] != undefined &&
			newData[newIndex + 7].type == "LOGO" &&
			newData[newIndex + 8] != undefined &&
			newData[newIndex + 8].type == "LOGO"
		) {
			if (isPass) {
				isPass = false;
				let newItemss = {};
				newItemss.type = "LOGO";
				(newItemss.isTrue = false),
				(newItemss.bjSrc = [
					...newItem.bjSrc,
					...newData[newIndex + 1].bjSrc,
					...newData[newIndex + 2].bjSrc,
					...newData[newIndex + 3].bjSrc,
					...newData[newIndex + 4].bjSrc,
					...newData[newIndex + 5].bjSrc,
					...newData[newIndex + 6].bjSrc,
					...newData[newIndex + 7].bjSrc,
					...newData[newIndex + 8].bjSrc
				]);
				newItemss.brands = [
					...newItem.brands,
					[],
					...newData[newIndex + 1].brands,
					[],
					...newData[newIndex + 2].brands,
					[],
					...newData[newIndex + 3].brands,
					[],
					...newData[newIndex + 4].brands,
					[],
					...newData[newIndex + 5].brands,
					[],
					...newData[newIndex + 6].brands,
					[],
					...newData[newIndex + 7].brands,
					[],
					...newData[newIndex + 8].brands
				];
				NewDatas.push(newItemss);
			}
		} else if (
			newItem.type == "LOGO" &&
			newData[newIndex + 1] != undefined &&
			newData[newIndex + 1].type == "LOGO" &&
			newData[newIndex + 2] != undefined &&
			newData[newIndex + 2].type == "LOGO" &&
			newData[newIndex + 3] != undefined &&
			newData[newIndex + 3].type == "LOGO" &&
			newData[newIndex + 4] != undefined &&
			newData[newIndex + 4].type == "LOGO" &&
			newData[newIndex + 5] != undefined &&
			newData[newIndex + 5].type == "LOGO" &&
			newData[newIndex + 6] != undefined &&
			newData[newIndex + 6].type == "LOGO" &&
			newData[newIndex + 7] != undefined &&
			newData[newIndex + 7].type == "LOGO"
		) {
			if (isPass) {
				isPass = false;
				let newItemss = {};
				newItemss.type = "LOGO";
				(newItemss.isTrue = false),
				(newItemss.bjSrc = [
					...newItem.bjSrc,
					...newData[newIndex + 1].bjSrc,
					...newData[newIndex + 2].bjSrc,
					...newData[newIndex + 3].bjSrc,
					...newData[newIndex + 4].bjSrc,
					...newData[newIndex + 5].bjSrc,
					...newData[newIndex + 6].bjSrc,
					...newData[newIndex + 7].bjSrc
				]);
				newItemss.brands = [
					...newItem.brands,
					[],
					...newData[newIndex + 1].brands,
					[],
					...newData[newIndex + 2].brands,
					[],
					...newData[newIndex + 3].brands,
					[],
					...newData[newIndex + 4].brands,
					[],
					...newData[newIndex + 5].brands,
					[],
					...newData[newIndex + 6].brands,
					[],
					...newData[newIndex + 7].brands
				];
				NewDatas.push(newItemss);
			}
		} else if (
			newItem.type == "LOGO" &&
			newData[newIndex + 1] != undefined &&
			newData[newIndex + 1].type == "LOGO" &&
			newData[newIndex + 2] != undefined &&
			newData[newIndex + 2].type == "LOGO" &&
			newData[newIndex + 3] != undefined &&
			newData[newIndex + 3].type == "LOGO" &&
			newData[newIndex + 4] != undefined &&
			newData[newIndex + 4].type == "LOGO" &&
			newData[newIndex + 5] != undefined &&
			newData[newIndex + 5].type == "LOGO" &&
			newData[newIndex + 6] != undefined &&
			newData[newIndex + 6].type == "LOGO"
		) {
			if (isPass) {
				isPass = false;
				let newItemss = {};
				newItemss.type = "LOGO";
				(newItemss.isTrue = false),
				(newItemss.bjSrc = [
					...newItem.bjSrc,
					...newData[newIndex + 1].bjSrc,
					...newData[newIndex + 2].bjSrc,
					...newData[newIndex + 3].bjSrc,
					...newData[newIndex + 4].bjSrc,
					...newData[newIndex + 5].bjSrc,
					...newData[newIndex + 6].bjSrc
				]);
				newItemss.brands = [
					...newItem.brands,
					[],
					...newData[newIndex + 1].brands,
					[],
					...newData[newIndex + 2].brands,
					[],
					...newData[newIndex + 3].brands,
					[],
					...newData[newIndex + 4].brands,
					[],
					...newData[newIndex + 5].brands,
					[],
					...newData[newIndex + 6].brands
				];
				NewDatas.push(newItemss);
			}
		} else if (
			newItem.type == "LOGO" &&
			newData[newIndex + 1] != undefined &&
			newData[newIndex + 1].type == "LOGO" &&
			newData[newIndex + 2] != undefined &&
			newData[newIndex + 2].type == "LOGO" &&
			newData[newIndex + 3] != undefined &&
			newData[newIndex + 3].type == "LOGO" &&
			newData[newIndex + 4] != undefined &&
			newData[newIndex + 4].type == "LOGO" &&
			newData[newIndex + 5] != undefined &&
			newData[newIndex + 5].type == "LOGO"
		) {
			if (isPass) {
				isPass = false;
				let newItemss = {};
				newItemss.type = "LOGO";
				(newItemss.isTrue = false),
				(newItemss.bjSrc = [
					...newItem.bjSrc,
					...newData[newIndex + 1].bjSrc,
					...newData[newIndex + 2].bjSrc,
					...newData[newIndex + 3].bjSrc,
					...newData[newIndex + 4].bjSrc,
					...newData[newIndex + 5].bjSrc
				]);
				newItemss.brands = [
					...newItem.brands,
					[],
					...newData[newIndex + 1].brands,
					[],
					...newData[newIndex + 2].brands,
					[],
					...newData[newIndex + 3].brands,
					[],
					...newData[newIndex + 4].brands,
					[],
					...newData[newIndex + 5].brands
				];
				NewDatas.push(newItemss);
			}
		} else if (
			newItem.type == "LOGO" &&
			newData[newIndex + 1] != undefined &&
			newData[newIndex + 1].type == "LOGO" &&
			newData[newIndex + 2] != undefined &&
			newData[newIndex + 2].type == "LOGO" &&
			newData[newIndex + 3] != undefined &&
			newData[newIndex + 3].type == "LOGO" &&
			newData[newIndex + 4] != undefined &&
			newData[newIndex + 4].type == "LOGO"
		) {
			if (isPass) {
				// 
				isPass = false;
				let newItemss = {};
				newItemss.type = "LOGO";
				(newItemss.isTrue = false),
				console.log(
					"newData[newIndex+4].brands=========>",
					newData[newIndex + 4].brands
				);
				newItemss.bjSrc = [
					...newItem.bjSrc,
					...newData[newIndex + 1].bjSrc,
					...newData[newIndex + 2].bjSrc,
					...newData[newIndex + 3].bjSrc,
					...newData[newIndex + 4].bjSrc
				];
				newItemss.brands = [
					...newItem.brands,
					[],
					...newData[newIndex + 1].brands,
					[],
					...newData[newIndex + 2].brands,
					[],
					...newData[newIndex + 3].brands,
					[],
					...newData[newIndex + 4].brands
				];
				NewDatas.push(newItemss);
			}
		} else if (
			newItem.type == "LOGO" &&
			newData[newIndex + 1] != undefined &&
			newData[newIndex + 1].type == "LOGO" &&
			newData[newIndex + 2] != undefined &&
			newData[newIndex + 2].type == "LOGO" &&
			newData[newIndex + 3] != undefined &&
			newData[newIndex + 3].type == "LOGO"
		) {
			if (isPass) {
				isPass = false;
				let newItemss = {};
				newItemss.type = "LOGO";
				(newItemss.isTrue = false),
				(newItemss.bjSrc = [
					...newItem.bjSrc,
					...newData[newIndex + 1].bjSrc,
					...newData[newIndex + 2].bjSrc,
					...newData[newIndex + 3].bjSrc
				]);
				newItemss.brands = [
					...newItem.brands,
					[],
					...newData[newIndex + 1].brands,
					[],
					...newData[newIndex + 2].brands,
					[],
					...newData[newIndex + 3].brands
				];
				NewDatas.push(newItemss);
			}
		} else if (
			newItem.type == "LOGO" &&
			newData[newIndex + 1] != undefined &&
			newData[newIndex + 1].type == "LOGO" &&
			newData[newIndex + 2] != undefined &&
			newData[newIndex + 2].type == "LOGO"
		) {
			if (isPass) {
				isPass = false;
				let newItemss = {};
				newItemss.type = "LOGO";
				(newItemss.isTrue = false),
				(newItemss.bjSrc = [
					...newItem.bjSrc,
					...newData[newIndex + 1].bjSrc,
					...newData[newIndex + 2].bjSrc
				]);
				newItemss.brands = [
					...newItem.brands,
					[],
					...newData[newIndex + 1].brands,
					[],
					...newData[newIndex + 2].brands
				];
				NewDatas.push(newItemss);
			}
		} else if (
			newItem.type == "LOGO" &&
			newData[newIndex + 1] != undefined &&
			newData[newIndex + 1].type == "LOGO"
		) {
			if (isPass) {
				isPass = false;
				let newItemss = {};
				newItemss.type = "LOGO";
				(newItemss.isTrue = false),
				(newItemss.bjSrc = [
					...newItem.bjSrc,
					...newData[newIndex + 1].bjSrc
				]);
				newItemss.brands = [
					...newItem.brands,
					[],
					...newData[newIndex + 1].brands
				];
				NewDatas.push(newItemss);
			}
		} else if (
			newItem.type == "LOGO" &&
			newData[newIndex - 1].type != "LOGO" &&
			((newData[newIndex + 1] != undefined &&
					newData[newIndex + 1].type != "LOGO") ||
				newData[newIndex + 1] == undefined)
		) {
			NewDatas.push(newItem);
		}
	});
	// console.log("NewDatas=========>", NewDatas);
	// let NxutDatas = [];
	NewDatas.forEach((item, index) => {
		item.id = `${item.type}_${index}`

	});

	// 数据再加工
	NewDatas.forEach((item, index) => {
		if (item.type == "LOGO") {
			item.brands.forEach((oneItem, oneIndex) => {
				if (oneIndex <= 6) {
					oneItem.isDisplay = true
				}
				if (oneItem.arr) {
					oneItem.arr.forEach((twoItem, twoIndex) => {
						if (twoItem.length != 0) {
							twoItem.id = `${item.id}-${oneIndex}_${twoIndex}`
						}
					});
				}

			})
		}
	});
	// console.log('NewDatas==========>', NewDatas)
	return NewDatas;
}
